package com.datam.controller;

import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.datam.dao.CompanyContactDAO;
import com.datam.domain.CompanyContactDO;
import com.datam.query.QueryCompanyContact;
import com.datam.query.QueryCompanyInfo;
import com.datam.utils.DMResult; 


@Controller
public class ContactController {
	
	@Autowired  
	CompanyContactDAO companyContactDAO ;
	
	@RequestMapping("VOCsCompany/GetContactData")
	public @ResponseBody Object GetCompanyID(HttpServletRequest request, HttpServletResponse response,
			QueryCompanyContact queryCompanyContact){
		HashMap r = new HashMap();
		List< CompanyContactDO > data = companyContactDAO.selectCompanyContactList(queryCompanyContact);
		r.put("total", companyContactDAO.countCompanyContactList(queryCompanyContact));
		r.put("rows", data);
		return 	r	;
		
	}
	
	@RequestMapping("VOCsCompany/saveCompanyContactData")
	public @ResponseBody Object saveCompanyContactData(
			CompanyContactDO companyContactDO){
		if(companyContactDO.getID()==null){
			companyContactDAO.insertCompanyContact(companyContactDO);
		}else{
			companyContactDAO.updateCompanyContactById(companyContactDO);
		}
		return new DMResult("插入成功",true);

	}
	
	@RequestMapping("VOCsCompany/DelCompanyContactInfoByID")
	public @ResponseBody Object DelCompanyContactInfoByID(
			Long ID){
		companyContactDAO.deleteById(ID);
		return new DMResult("刪除成功",true);

	}

}
